Index: ioemu/hw/mc146818rtc.c
===================================================================
---- ioemu.orig/hw/mc146818rtc.c 2006-08-08 11:27:33.924822567 +0100
-+++ ioemu/hw/mc146818rtc.c 2006-08-08 11:28:01.929698228 +0100
+--- ioemu.orig/hw/mc146818rtc.c 2006-08-09 15:04:17.857242121 +0100
++++ ioemu/hw/mc146818rtc.c 2006-08-09 15:04:24.588603423 +0100
@@ -178,10 +178,27 @@
}
}
static void rtc_copy_date(RTCState *s)
Index: ioemu/hw/pc.c
===================================================================
---- ioemu.orig/hw/pc.c 2006-08-08 11:27:58.117123572 +0100
-+++ ioemu/hw/pc.c 2006-08-08 11:28:01.930698117 +0100
+--- ioemu.orig/hw/pc.c 2006-08-09 15:04:24.316629266 +0100
++++ ioemu/hw/pc.c 2006-08-09 15:04:24.589603328 +0100
@@ -159,7 +159,7 @@
}
QEMUMachine pc_machine = {
Index: ioemu/vl.c
===================================================================
---- ioemu.orig/vl.c 2006-08-08 11:28:01.787714069 +0100
-+++ ioemu/vl.c 2006-08-08 11:28:01.933697782 +0100
+--- ioemu.orig/vl.c 2006-08-09 15:04:24.457615869 +0100
++++ ioemu/vl.c 2006-08-09 15:04:24.592603043 +0100
@@ -163,6 +163,8 @@
int xc_handle;
if (usb_enabled) {
Index: ioemu/vl.h
===================================================================
---- ioemu.orig/vl.h 2006-08-08 11:28:01.517744187 +0100
-+++ ioemu/vl.h 2006-08-08 11:28:01.934697671 +0100
+--- ioemu.orig/vl.h 2006-08-09 15:04:24.321628791 +0100
++++ ioemu/vl.h 2006-08-09 15:04:24.593602948 +0100
@@ -575,7 +575,7 @@
int boot_device,
DisplayState *ds, const char **fd_filename, int snapshot,
vnc-start-vncviewer
vnc-title-domain-name
vnc-access-monitor-vt
+vnc-display-find-unused
xenstore-block-device-config
xenstore-write-vnc-port
qemu-allow-disable-sdl
--- /dev/null
+Index: ioemu/vnc.c
+===================================================================
+--- ioemu.orig/vnc.c 2006-08-09 14:44:44.721942535 +0100
++++ ioemu/vnc.c 2006-08-09 14:52:37.262165292 +0100
+@@ -1183,7 +1183,7 @@
+ }
+ }
+
+-void vnc_display_init(DisplayState *ds, int display)
++int vnc_display_init(DisplayState *ds, int display, int find_unused)
+ {
+ struct sockaddr_in addr;
+ int reuse_addr, ret;
+@@ -1214,10 +1214,6 @@
+ exit(1);
+ }
+
+- addr.sin_family = AF_INET;
+- addr.sin_port = htons(5900 + display);
+- memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
+-
+ reuse_addr = 1;
+ ret = setsockopt(vs->lsock, SOL_SOCKET, SO_REUSEADDR,
+ (const char *)&reuse_addr, sizeof(reuse_addr));
+@@ -1226,7 +1222,16 @@
+ exit(1);
+ }
+
++ retry:
++ addr.sin_family = AF_INET;
++ addr.sin_port = htons(5900 + display);
++ memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
++
+ if (bind(vs->lsock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
++ if (find_unused && errno == EADDRINUSE) {
++ display++;
++ goto retry;
++ }
+ fprintf(stderr, "bind() failed\n");
+ exit(1);
+ }
+@@ -1247,6 +1252,8 @@
+ vs->ds->dpy_refresh = vnc_dpy_refresh;
+
+ vnc_dpy_resize(vs->ds, 640, 400);
++
++ return display;
+ }
+
+ int vnc_start_viewer(int port)
+Index: ioemu/vl.c
+===================================================================
+--- ioemu.orig/vl.c 2006-08-09 14:44:44.721942535 +0100
++++ ioemu/vl.c 2006-08-09 14:52:06.783905832 +0100
+@@ -121,6 +121,7 @@
+ static DisplayState display_state;
+ int nographic;
+ int vncviewer;
++int vncunused;
+ const char* keyboard_layout = NULL;
+ int64_t ticks_per_sec;
+ int boot_device = 'c';
+@@ -5342,6 +5343,7 @@
+ "-loadvm file start right away with a saved state (loadvm in monitor)\n"
+ "-vnc display start a VNC server on display\n"
+ "-vncviewer start a vncviewer process for this domain\n"
++ "-vncunused bind the VNC server to an unused port\n"
+ "-timeoffset time offset (in seconds) from local time\n"
+ "-acpi disable or enable ACPI of HVM domain \n"
+ "\n"
+@@ -5431,6 +5433,7 @@
+ QEMU_OPTION_timeoffset,
+ QEMU_OPTION_acpi,
+ QEMU_OPTION_vncviewer,
++ QEMU_OPTION_vncunused,
+ };
+
+ typedef struct QEMUOption {
+@@ -5506,6 +5509,7 @@
+ { "smp", HAS_ARG, QEMU_OPTION_smp },
+ { "vnc", HAS_ARG, QEMU_OPTION_vnc },
+ { "vncviewer", 0, QEMU_OPTION_vncviewer },
++ { "vncunused", 0, QEMU_OPTION_vncunused },
+
+ /* temporary options */
+ { "usb", 0, QEMU_OPTION_usb },
+@@ -5873,6 +5877,7 @@
+ snapshot = 0;
+ nographic = 0;
+ vncviewer = 0;
++ vncunused = 0;
+ kernel_filename = NULL;
+ kernel_cmdline = "";
+ #ifdef TARGET_PPC
+@@ -6270,6 +6275,11 @@
+ case QEMU_OPTION_vncviewer:
+ vncviewer++;
+ break;
++ case QEMU_OPTION_vncunused:
++ vncunused++;
++ if (vnc_display == -1)
++ vnc_display = -2;
++ break;
+ }
+ }
+ }
+@@ -6465,7 +6475,7 @@
+ if (nographic) {
+ dumb_display_init(ds);
+ } else if (vnc_display != -1) {
+- vnc_display_init(ds, vnc_display);
++ vnc_display = vnc_display_init(ds, vnc_display, vncunused);
+ if (vncviewer)
+ vnc_start_viewer(vnc_display);
+ } else {
+Index: ioemu/vl.h
+===================================================================
+--- ioemu.orig/vl.h 2006-08-09 14:44:44.721942535 +0100
++++ ioemu/vl.h 2006-08-09 14:52:06.783905832 +0100
+@@ -784,7 +784,7 @@
+ void cocoa_display_init(DisplayState *ds, int full_screen);
+
+ /* vnc.c */
+-void vnc_display_init(DisplayState *ds, int display);
++int vnc_display_init(DisplayState *ds, int display, int find_unused);
+ int vnc_start_viewer(int port);
+
+ /* ide.c */
Index: ioemu/vl.c
===================================================================
---- ioemu.orig/vl.c 2006-08-08 14:33:30.000000000 +0100
-+++ ioemu/vl.c 2006-08-08 14:43:34.000000000 +0100
-@@ -5834,6 +5834,7 @@
+--- ioemu.orig/vl.c 2006-08-09 15:04:25.583508863 +0100
++++ ioemu/vl.c 2006-08-09 15:04:26.034465993 +0100
+@@ -5838,6 +5838,7 @@
unsigned long nr_pages;
xen_pfn_t *page_array;
extern void *shared_page;
char qemu_dm_logfilename[64];
-@@ -6378,12 +6379,17 @@
+@@ -6388,12 +6389,17 @@
phys_ram_base = xc_map_foreign_batch(xc_handle, domid,
PROT_READ|PROT_WRITE, page_array,
page_array[nr_pages - 1]);
Index: ioemu/target-i386-dm/helper2.c
===================================================================
---- ioemu.orig/target-i386-dm/helper2.c 2006-08-08 14:33:30.000000000 +0100
-+++ ioemu/target-i386-dm/helper2.c 2006-08-09 10:03:40.558744653 +0100
+--- ioemu.orig/target-i386-dm/helper2.c 2006-08-09 15:04:24.105649313 +0100
++++ ioemu/target-i386-dm/helper2.c 2006-08-09 15:04:26.040465422 +0100
@@ -76,6 +76,10 @@
shared_iopage_t *shared_page = NULL;
Index: ioemu/Makefile.target
===================================================================
---- ioemu.orig/Makefile.target 2006-08-07 17:42:27.802386071 +0100
-+++ ioemu/Makefile.target 2006-08-07 17:42:28.683289358 +0100
+--- ioemu.orig/Makefile.target 2006-08-09 15:04:24.795583755 +0100
++++ ioemu/Makefile.target 2006-08-09 15:04:25.373528824 +0100
@@ -358,6 +358,7 @@
VL_OBJS+= cirrus_vga.o mixeng.o parallel.o acpi.o piix_pci.o
VL_OBJS+= usb-uhci.o
Index: ioemu/xenstore.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ ioemu/xenstore.c 2006-08-07 17:42:28.684289249 +0100
++++ ioemu/xenstore.c 2006-08-09 15:04:25.374528729 +0100
@@ -0,0 +1,187 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General
+}
Index: ioemu/vl.c
===================================================================
---- ioemu.orig/vl.c 2006-08-07 17:42:28.393320909 +0100
-+++ ioemu/vl.c 2006-08-07 17:42:28.687288922 +0100
-@@ -5242,9 +5242,11 @@
+--- ioemu.orig/vl.c 2006-08-09 15:04:25.312534622 +0100
++++ ioemu/vl.c 2006-08-09 15:04:25.377528443 +0100
+@@ -5243,9 +5243,11 @@
"Standard options:\n"
"-M machine select emulated machine (-M ? for list)\n"
"-fda/-fdb file use 'file' as floppy disk 0/1 image\n"
"-boot [a|c|d] boot on floppy (a), hard disk (c) or CD-ROM (d)\n"
"-snapshot write to temporary files instead of disk image files\n"
#ifdef TARGET_I386
-@@ -5370,11 +5372,13 @@
+@@ -5372,11 +5374,13 @@
QEMU_OPTION_M,
QEMU_OPTION_fda,
QEMU_OPTION_fdb,
QEMU_OPTION_boot,
QEMU_OPTION_snapshot,
#ifdef TARGET_I386
-@@ -5445,11 +5449,13 @@
+@@ -5448,11 +5452,13 @@
{ "M", HAS_ARG, QEMU_OPTION_M },
{ "fda", HAS_ARG, QEMU_OPTION_fda },
{ "fdb", HAS_ARG, QEMU_OPTION_fdb },
{ "boot", HAS_ARG, QEMU_OPTION_boot },
{ "snapshot", 0, QEMU_OPTION_snapshot },
#ifdef TARGET_I386
-@@ -5797,10 +5803,16 @@
+@@ -5801,10 +5807,16 @@
#ifdef CONFIG_GDBSTUB
int use_gdbstub, gdbstub_port;
#endif
const char *kernel_filename, *kernel_cmdline;
DisplayState *ds = &display_state;
int cyls, heads, secs, translation;
-@@ -5861,8 +5873,10 @@
+@@ -5865,8 +5877,10 @@
initrd_filename = NULL;
for(i = 0; i < MAX_FD; i++)
fd_filename[i] = NULL;
ram_size = DEFAULT_RAM_SIZE * 1024 * 1024;
vga_ram_size = VGA_RAM_SIZE;
bios_size = BIOS_SIZE;
-@@ -5875,11 +5889,13 @@
- vncviewer = 0;
+@@ -5880,11 +5894,13 @@
+ vncunused = 0;
kernel_filename = NULL;
kernel_cmdline = "";
+#ifndef CONFIG_DM
cyls = heads = secs = 0;
translation = BIOS_ATA_TRANSLATION_AUTO;
pstrcpy(monitor_device, sizeof(monitor_device), "vc");
-@@ -5912,7 +5928,11 @@
+@@ -5917,7 +5933,11 @@
break;
r = argv[optind];
if (r[0] != '-') {
} else {
const QEMUOption *popt;
-@@ -5956,6 +5976,7 @@
+@@ -5961,6 +5981,7 @@
case QEMU_OPTION_initrd:
initrd_filename = optarg;
break;
case QEMU_OPTION_hda:
case QEMU_OPTION_hdb:
case QEMU_OPTION_hdc:
-@@ -5968,6 +5989,7 @@
+@@ -5973,6 +5994,7 @@
cdrom_index = -1;
}
break;
case QEMU_OPTION_snapshot:
snapshot = 1;
break;
-@@ -6020,11 +6042,13 @@
+@@ -6025,11 +6047,13 @@
case QEMU_OPTION_append:
kernel_cmdline = optarg;
break;
case QEMU_OPTION_boot:
boot_device = optarg[0];
if (boot_device != 'a' &&
-@@ -6274,12 +6298,18 @@
+@@ -6284,12 +6308,18 @@
}
}
if (!linux_boot &&
hd_filename[0] == '\0' &&
(cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
-@@ -6293,6 +6323,7 @@
+@@ -6303,6 +6333,7 @@
else
boot_device = 'd';
}
setvbuf(stdout, NULL, _IOLBF, 0);
-@@ -6407,6 +6438,7 @@
+@@ -6417,6 +6448,7 @@
#endif /* !CONFIG_DM */
/* we always create the cdrom drive, even if no disk is there */
bdrv_init();
if (cdrom_index >= 0) {
-@@ -6433,6 +6465,7 @@
+@@ -6443,6 +6475,7 @@
}
}
}
/* we always create at least one floppy disk */
fd_table[0] = bdrv_new("fda");
-@@ -6511,6 +6544,8 @@
+@@ -6521,6 +6554,8 @@
}
}
kernel_filename, kernel_cmdline, initrd_filename,
Index: ioemu/monitor.c
===================================================================
---- ioemu.orig/monitor.c 2006-08-07 17:42:27.132461888 +0100
-+++ ioemu/monitor.c 2006-08-07 17:42:28.688288814 +0100
+--- ioemu.orig/monitor.c 2006-08-09 15:04:24.105649313 +0100
++++ ioemu/monitor.c 2006-08-09 15:04:25.379528253 +0100
@@ -24,6 +24,7 @@
#include "vl.h"
#include "disas.h"
int i;
Index: ioemu/block.c
===================================================================
---- ioemu.orig/block.c 2006-08-07 17:42:21.704076241 +0100
-+++ ioemu/block.c 2006-08-07 17:42:28.689288705 +0100
+--- ioemu.orig/block.c 2006-08-09 15:04:17.487277167 +0100
++++ ioemu/block.c 2006-08-09 15:04:25.379528253 +0100
@@ -758,6 +758,7 @@
static void raw_close(BlockDriverState *bs)
{
Index: ioemu/vl.h
===================================================================
---- ioemu.orig/vl.h 2006-08-07 17:42:28.394320800 +0100
-+++ ioemu/vl.h 2006-08-07 17:42:28.689288705 +0100
+--- ioemu.orig/vl.h 2006-08-09 15:04:25.313534527 +0100
++++ ioemu/vl.h 2006-08-09 15:04:25.380528158 +0100
@@ -1184,6 +1184,8 @@
void term_print_help(void);
void monitor_readline(const char *prompt, int is_password,
extern char domain_name[];
Index: ioemu/hw/ide.c
===================================================================
---- ioemu.orig/hw/ide.c 2006-08-07 17:42:27.552414361 +0100
-+++ ioemu/hw/ide.c 2006-08-07 17:42:28.691288487 +0100
+--- ioemu.orig/hw/ide.c 2006-08-09 15:04:24.524609503 +0100
++++ ioemu/hw/ide.c 2006-08-09 15:04:25.381528063 +0100
@@ -1158,6 +1158,7 @@
} else {
ide_atapi_cmd_error(s, SENSE_NOT_READY,
Index: ioemu/xenstore.c
===================================================================
---- ioemu.orig/xenstore.c 2006-08-07 17:42:28.684289249 +0100
-+++ ioemu/xenstore.c 2006-08-07 17:42:28.891266728 +0100
+--- ioemu.orig/xenstore.c 2006-08-09 15:04:25.374528729 +0100
++++ ioemu/xenstore.c 2006-08-09 15:04:25.579509243 +0100
@@ -185,3 +185,31 @@
free(image);
free(vec);
+}
Index: ioemu/vl.c
===================================================================
---- ioemu.orig/vl.c 2006-08-07 17:42:28.687288922 +0100
-+++ ioemu/vl.c 2006-08-07 17:42:28.894266401 +0100
-@@ -6501,6 +6501,7 @@
- vnc_display_init(ds, vnc_display);
+--- ioemu.orig/vl.c 2006-08-09 15:04:25.377528443 +0100
++++ ioemu/vl.c 2006-08-09 15:04:25.583508863 +0100
+@@ -6511,6 +6511,7 @@
+ vnc_display = vnc_display_init(ds, vnc_display, vncunused);
if (vncviewer)
vnc_start_viewer(vnc_display);
+ xenstore_write_vncport(vnc_display);
sdl_display_init(ds, full_screen);
Index: ioemu/vl.h
===================================================================
---- ioemu.orig/vl.h 2006-08-07 17:42:28.689288705 +0100
-+++ ioemu/vl.h 2006-08-07 17:42:28.895266293 +0100
+--- ioemu.orig/vl.h 2006-08-09 15:04:25.380528158 +0100
++++ ioemu/vl.h 2006-08-09 15:04:25.584508768 +0100
@@ -1203,6 +1203,7 @@
int xenstore_fd(void);
void xenstore_process_event(void *opaque);